<template>
    <div>
        <van-cell-group class="notice-group">
            <van-card @click="orderDetail(item.order_id)" class="notice-cell" v-for="(item,i) in itemList" :key="i"
                      :title="item.goods_name"
                      :desc="item.goods_desc"
                      :thumb="getUrl(item.goods_img)"
                      :price="item.price"
                      :num="item.count"
            >
                <template #footer>
                    <van-button size="small" type="primary" @click="delivery(item.id)">发货</van-button>
                </template>
            </van-card>
        </van-cell-group>

    </div>
</template>

<script>


import {undelivery} from "@/api/order";
import {delivery} from "../../api/order";

export default {
    name: "DeliveryNotice",
    created() {
        this.getDeliveryOrder();
    },
    data() {
        return {
            itemList: []
        }
    },
    methods: {
        orderDetail(orderId) {
            this.$router.push({name: "order_show", params: {id: orderId}})
        },
        async getDeliveryOrder() {
            let result = await undelivery();
            this.itemList = this.utils.resultList(result)
        },
        async delivery(id) {
            let result = await delivery({id: id})
            this.utils.resultEnd(result, "发货")
        },
        getUrl(url) {
            return this.baseUrl + url
        }
    }
}
</script>

<style lang="scss" scoped>
.notice-group {

    margin-top: 20px;

    .notice-cell {
        width: 100%;
    }
}


</style>
